home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8322 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  60 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.dcs.warwick.ac.uk!not-for-mail
  3. From: D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero)
  4. Subject: dereferencing pointer to incomplete type
  5. X-Nntp-Posting-Host: angel
  6. Message-ID: <1996Mar3.040741.27234@dcs.warwick.ac.uk>
  7. Sender: news@dcs.warwick.ac.uk (Network News)
  8. Organization: Department of Computer Science, Warwick University, England
  9. Date: Sun, 3 Mar 1996 04:07:41 GMT
  10.  
  11.  
  12. Hi everybody.
  13. I wonder if anybody can help me to debug the short code below.
  14. It is supposed to calculate the area of a polygon, but when I compile
  15. it with  gcc program.c, it gives me the following errors,
  16.  
  17. program.c: In function `calc_area':
  18. program.c:22: warning: assignment from incompatible pointer type
  19. program.c:24: dereferencing pointer to incomplete type
  20. program.c:24: dereferencing pointer to incomplete type
  21. program.c:26: warning: assignment from incompatible pointer type
  22.  
  23.  
  24. which I don't understand at all.
  25.  
  26. I would appreciate very much any sort of help.
  27.  
  28. ------------------
  29.  
  30. struct polygon
  31. {
  32.   int tried;
  33.   double x, y;
  34.   int dir, numtimes, conv;
  35.   struct polyg *next;
  36. };
  37.  
  38.  
  39. void triang(double a0, double a1, double b0, double b1, double c0, \
  40.             double c1, double* result) {
  41.   *result = a0 * b1 - a1 * b0 + \
  42.             a1 * c0 - a0 * c1 + \
  43.             b0 * c1 - c0 * b1;
  44. }
  45.  
  46. void calc_area(struct polygon* polyg, double* area) {
  47. struct polygon* p;
  48. double result;
  49. p = polyg->next;
  50. while (p->next != 0) {
  51.   triang(polyg->x, polyg->y, p->x, p->y, (p->next)->x, (p->next)->y, &result);
  52.   *area = *area + result;
  53.   p = p->next;
  54. }
  55. }
  56. -- 
  57. * Daniel Castillo.  danmol@dcs.warwick.ac.uk *
  58.  
  59.  
  60.